Imports System
Imports System.Data
Imports System.Data.Common
Imports System.Collections.Generic
Imports Microsoft.Practices.EnterpriseLibrary.Data

Namespace DAL.Externo
	Public Class Persona
		Public Function Listar() As DataTable
            Dim ds As New DataSet()
            Dim db As Database = DatabaseFactory.CreateDatabase()
            Dim cm As System.Data.Common.DbCommand = db.GetStoredProcCommand("[PER_S_PERSONA]")

            Try
                ds = db.ExecuteDataSet(cm)
                ds.Tables(0).TableName = "PERSONAS"
                Return ds.Tables(0)
            Catch ex As System.Data.SqlClient.SqlException
                Throw New Exception(ex.Message, ex.InnerException)
            End Try
        End Function
        Public Function Listar_Naturales(ByVal _Parametros As Object()) As DataTable
            Dim ds As New DataSet()
            Dim db As Database = DatabaseFactory.CreateDatabase()
            Dim cm As System.Data.Common.DbCommand = db.GetStoredProcCommand("[PER_S_NATURAL]")
            db.AddInParameter(cm, "FL_PERSONAL", DbType.Int32, Convert.ToInt32(_Parametros(0)))
            db.AddInParameter(cm, "FL_SOCIO", DbType.Int32, Convert.ToInt32(_Parametros(1)))
            db.AddInParameter(cm, "NO_DOCIDENTIDAD", DbType.String, Convert.ToString(_Parametros(2)))

            Try
                ds = db.ExecuteDataSet(cm)
                ds.Tables(0).TableName = "PERSONAS_NATURALES"
                Return ds.Tables(0)
            Catch ex As System.Data.SqlClient.SqlException
                Throw New Exception(ex.Message, ex.InnerException)
            End Try
        End Function
        Public Function Listar_Juridicas() As DataTable
            Dim ds As New DataSet()
            Dim db As Database = DatabaseFactory.CreateDatabase()
            Dim cm As System.Data.Common.DbCommand = db.GetStoredProcCommand("[PER_S_JURIDICA]")

            Try
                ds = db.ExecuteDataSet(cm)
                ds.Tables(0).TableName = "PERSONAS_JURIDICAS"
                Return ds.Tables(0)
            Catch ex As System.Data.SqlClient.SqlException
                Throw New Exception(ex.Message, ex.InnerException)
            End Try
        End Function
	End Class
End Namespace